<template>
    <div o-Container>
      <o-list v-bind:source="list.contract" v-bind="{ exported: output }">
        <template slot="config" slot-scope="scope">
          <div class="img_box">
            <img @click="showLookDiaolog(scope, '1')"
              src="/static/skin/default/MCS/AIGC/Inventory/images/chakan.png" alt="">
            <img @click="showLookDiaolog(scope, '2')" :class="{disable: !isDisabled(scope.data.row)}"
              src="/static/skin/default/MCS/AIGC/Inventory/images/tongguo.png" alt="">
            <img @click="showLookDiaolog(scope, '3')" :class="{disable: !isDisabled(scope.data.row)}"
              src="/static/skin/default/MCS/AIGC/Inventory/images/bohui.png" alt="">
          </div>
        </template>
      </o-list>
      <AfterSaleOrderMsg ref="SalesOrderMsg" :orderType="orderType" :messageList="messageList" @refresh="refresh"></AfterSaleOrderMsg>
    </div>
  </template>
  
  <script>
  import AfterSaleOrderMsg from '../Components/AfterSaleOrderMsg.vue'
  export default {
    components: {
      AfterSaleOrderMsg
    },
    name: "mms_platform_company_list", /* 这个name暂时不知道用啥用，根据官方文档说的是方便排错的 */
    data() {
      return {
        octopus: this.$parent.octopus,
        list: {
          contract: {
            data: {
              id: 1217, // 菜单表的八爪鱼ID
              cellData: [
                {name: "PayCode", width: 180},	// 交易订单
                {name: "EquityID", show: false},  // 权益ID
                {name: "EquityName", width: 360},	// 权益名称
                {name: "PurchaseName", width: 180},	// 买家
                {name: "RefundReasons", width: 300},	// 退款原因
                {name: "Status"},	// 售后状态
                {name: "StatusID", show: false},	// 售后状态
                {name: "ProductName", width: 160},	// 产品名称
                {name: "ProductFlagList", show: false},	// 产品标签
	              {name: "ProductFlagListName", width: 160},	// 产品标签
                {name: "RefundQuantity", show: false},	// 退款数量
                {name: "RefundAmount"},	// 退款金额
                {name: "ServiceCharge"},	// 手续费（元）
                {name: "BuyQuantity"},	// 购买数量
                {name: "UserPayTotalPrice"},	// 购买金额（元）
                {name: "RefundPlatformID"},	// 退款渠道
                {name: "CompanyID"},	// 卖家
                {name: "CompanyIDName", show: false},	// 卖家
                {name: "RefundTime", width: 160},	// 申请退货时间
                {name: "PurchaseTime", width: 160},	// 下单时间
                {name: "ID", show: false},	// ID
                {name: "ServiceCompany", show: false},	// 服务方
                {name: "PurchasePlatformID", show: false},	// 购买渠道
                {name: "OutRefundCode", show: false}, //OutRefundCode
                {name: "RefundCharge", show: false},	// 退款手续费
                {name: "TypeID", show: false},	// TypeID
                {name: "PurchaseID", show: false},	// 订单ID
                {name: "IsRefundAudit", show: false},	// IsRefundAudit
                {name: "RefundID", show: false},	// 退款ID
                {name: "PID", show: false},	// PID
                {name: "BtnStatusID", show: false},	// BtnStatusID
                {name: "PurchaserID", show: false},	//  买家ID
                {name: "MerchantID", show: false},	// 买家公司id
              ],
              paramData: {}
            },
            configWidth: 80,
            showNumber: true,
          },
        },
        repetition: true,
        messageList: {},
        messageListAdd: {},
        orderType: 1,
      }
    },
    created() {
      this.init()
    },
    methods: {
      init() {
        const data = this.list.contract.data
        let company = this.octopus.passport.authorization.company
        data.paramData.CompanyID = company == 1 ? 'NULL' : company
      },
      isDisabled(row) {
        return (row.BtnStatusID == 1 && this.octopus.passport.authorization.company == 1) || (row.StatusID == 5 && this.octopus.passport.authorization.company !=1)
      },
      showLookDiaolog(row, type = 1) {
        if(type != 1 && !this.isDisabled(row.data.row)) {
          return
        }

        this.orderType = type
        this.messageList = row.data.row
        this.$nextTick(()=>{
          this.$refs.SalesOrderMsg.drawerOp(row.data.row.PurchaseID,'售后订单1217')
        })
      },
      output: function (data) {
        this.octopus.tips.success("下载完成。");
      },
      search: function (cell) {
      },
      save: function (data) {// 保存
        this.octopus.tips.success(data);
        // 刷新list
        this.list.contract.control.load();
        this.back();
      },
      back: function () {
        this.panel.visible = false;
      },
      refresh() {
        // const data = this.list.contract.data
        // let company = this.octopus.passport.authorization.company
        // data.paramData.CompanyID = company == 1 ? 'NULL' : company
        this.list.contract.control.load();
      },
    },
    props: ["oData"]
  }
  </script>
  <style scoped>
  .el-message-box {
    background-color: #fff !important;
  }
  
  .img_box {
    display: flex;
    justify-content: space-between;
    width: 100%;
  }
  
  .img_box img {
    width: 25px;
    cursor: pointer;
  }
  .disable {
    cursor: not-allowed;
    opacity: 0.5;
  }
  </style>
  